package com.eric.windows.event;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;

import com.eric.windows.R;

import org.androidannotations.annotations.AfterExtras;
import org.androidannotations.annotations.AfterInject;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.Extra;

/**
 * 跟随手指的小球
 */
@EActivity(R.layout.activity_circle_test)
public class CircleTestActivity extends Activity {

    /**
     * 将在ConfigurationTestActivity_中声明一个静态变量，这个变量值是由intent（其他界面跳转到该界面使用intent ）中获取的 ，如：
     * public final static String MY_MESSAGE_EXTRA = "myStringExtra";
     *  获取Extras数据后，可以在AfterExtras注解的方法中处理 {@link #doSomethingAfterExtrasInjection()}
     */
    @Extra("myStringExtra")
    String myMessage;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //去掉窗口标题
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        //全屏幕显示
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
//        setContentView();
    }

    @AfterViews
    void initData(){
        Intent  intent = new Intent();
        intent.putExtra("intent_data","数据2222");
        intent.setAction("com.eric.windows.update");
        sendBroadcast(intent);

        Intent  intent2 = new Intent();
        intent.putExtra("intent_data","数据");
        setResult(RESULT_OK,intent2);
    }

    /**
     * 获取Extras数据后，可以在AfterExtras注解的方法中处理
     */
    @AfterExtras
    public void doSomethingAfterExtrasInjection() {
        // someExtra and anotherExtra are set to the value contained in the incoming intent
        // if an intent does not contain one of the extra values the field remains unchanged
        Toast.makeText(this, myMessage, Toast.LENGTH_SHORT).show();

    }

}
